<!--
 * @Author: 花香蝶自来 1026583651@qq.com
 * @Date: 2024-04-16 18:35:31
 * @LastEditors: libing 964368540@qq.com
 * @LastEditTime: 2024-06-12 23:19:24
 * @FilePath: /crm/components/tabbar/tabbar.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view>
    <u-tabbar
      :value="value"
      @change="change"
      :fixed="true"
      :placeholder="true"
      :safeAreaInsetBottom="true"
    >
      <u-tabbar-item
        v-for="item in list"
        :text="item.text"
        :icon="item.icon"
      ></u-tabbar-item>
      <!-- <u-tabbar-item text="客户池" icon="photo"></u-tabbar-item>
      <u-tabbar-item text="我的" icon="account"></u-tabbar-item> -->
    </u-tabbar>
  </view>
</template>

<script>
export default {
  name: "tabbar",
  data() {
    return {
      value: "0",
      // imgs1: ['e520de50887946a1a9872baed6f2df03.png', "bdfdd5de366243389589f2dc6e81cbc9.png",
      //   "deacffbb18414c24ae128310855e39e9.png"
      // ],
      // imgs2: ["691e8217156b4007add64c1b789a9ff5.png", "accc193f46dd4c0fa8f2ccdd87f79e41.png",
      //   "0f0b023e738e419691a2ab02dac34c3b.png"
      // ]
      imgs1: ["home.png", "list.png", "my.png"],
      imgs2: ["home-active.png", "list-active.png", "my-active.png"],
    };
  },
  computed: {
    list() {
      let v = this.value;
      let r = [
        {
          text: "首页",
          page: "/pagesecharts/index/index",
        },
        {
          text: "客户池",
          page: "/pagescustomer/customer/customer",
        },
        {
          text: "我的",
          page: "/pages/my/my",
        },
      ].map((e, i) => {
        let img = this.imgs1[i];
        if (v == i) {
          img = this.imgs2[i];
        }
        return {
          ...e,
          icon: this.$z.imgsrc(img),
        };
      });
      return r;
    },
  },

  module() {},
  mounted() {
    this.init();
  },
  // ready
  methods: {
    init() {
      let pages = getCurrentPages();
      console.log(pages);
      let fullPath = pages[pages.length - 1].$page.fullPath;
      let i = this.list.findIndex((e) => {
        return e.page == fullPath;
      });
      this.value = String(i);
    },
    change(item) {
      // this.value = item
      let dqitem = this.list[item];
      uni.reLaunch({
        url: dqitem.page,
      });
      console.log(item, this.value);
    },
  },
};
</script>

<style></style>
